package com.lijiajia.cloud.authserver.pojo.mongodb;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.time.LocalDateTime;
import java.util.Set;

/**
 * 用户
 *
 * @author lijiajia
 * @since 2019-05-07
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@Document(collection = "user")
public class User {
    @Id
    @JsonIgnore
    private ObjectId mongoId;

    /**
     * 用户id
     */
    @Field(value = "user_id")
    private String id;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    @JsonIgnore
    private String password;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 手机号码
     */
    private String telephone;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 身份证号
     */
    private String idCardNo;

    /**
     * 启用
     */
    private Boolean enabled;

    /**
     * 角色
     */
    private Set<String> roleIds;

    /**
     * 删除
     */
    @JsonIgnore
    private Boolean deleted;

    /**
     * 创建时间
     */
    @CreatedDate
    private LocalDateTime createdAt;
    public static final String CREATED_AT = "created_at";
    /**
     * 最后修改时间
     */
    @LastModifiedDate
    private LocalDateTime lastModifiedAt;
    public static final String LAST_MODIFIED_AT = "last_modified_at";

    public static final String ID = "user_id";
    public static final String USERNAME = "username";
    public static final String PASSWORD = "password";
    public static final String NICKNAME = "nickname";
    public static final String EMAIL = "email";
    public static final String TELEPHONE = "telephone";
    public static final String AVATAR = "avatar";
    public static final String REAL_NAME = "real_name";
    public static final String ID_CARD_NO = "id_card_no";
    public static final String ENABLED = "enabled";
    public static final String ROLE_IDS = "role_ids";
    public static final String DELETED = "deleted";
}
